package java_exceptions.what_is_exception;

public class JavaException3 {

	public static void main(String[] args) {
		try {
			System.out.println("in main()");
			test1();
			System.out.println("after test1()"); //will be skipped
		} catch (ArithmeticException ex) {
			System.out.println("Exception caught :" + ex.getMessage());
		}

		System.out.println("main finished");
	}

	static void test1() {
		System.out.println("in test1()");
		test2();
		System.out.println("test1 finished"); //will be skipped
	}

	static void test2() {
		System.out.println("in test2()");
		int x = 10 / 0; // exception thrown
		// At this point control returned to test1()

		System.out.println("test2 finished"); //will be skipped
	}
}


